clear
NumMethod = 5;
rep = 100;
mean_budget = zeros(NumMethod,4); % prsmmo, prsmmo+ls, mommop, lams-aco, emo-mmo
var_budget = zeros(NumMethod,4);
samples = zeros(rep,4,NumMethod); % [rep, epsilon, method]
ProblemName = 'Composition3_3D';
% 'EqualMinima','Himmelblau','Sixhump','ModifiedRastrigin','Vincent',
% 'Shubert','Composition','IncreasingMinima','Rastrigin','Schaffer'.

work_space = load(['prsmmo\extract\a0.3_n4_10_d3\',ProblemName,'.mat']);
NumOpt = size(work_space.OptSet.sol,1);
samples(:,:,1) = 1-work_space.OptNoFound./NumOpt;
mean_budget(1,:) = mean(samples(:,:,1),1);
var_budget(1,:) = var(samples(:,:,1),[],1);

work_space = load(['prsmmo_ls\a0.3_n4_10_d3\',ProblemName,'.mat']);
samples(:,:,2) = 1-work_space.OptNoFound./NumOpt;
mean_budget(2,:) = mean(samples(:,:,2),1);
var_budget(2,:) = var(samples(:,:,2),[],1);

work_space = load(['mommop\data\',ProblemName,'.mat']);
samples(:,:,3) = 1-work_space.OptNoFound./NumOpt;
mean_budget(3,:) = mean(samples(:,:,3),1);
var_budget(3,:) = var(samples(:,:,3),[],1);

work_space = load(['lamsaco\v3\',ProblemName,'.mat']);
samples(:,:,4) = 1-work_space.OptNoFound./NumOpt;
mean_budget(4,:) = mean(samples(:,:,4),1);
var_budget(4,:) = var(samples(:,:,4),[],1);

work_space = load(['emommo\data\',ProblemName,'.mat']);
samples(:,:,5) = 1-work_space.OptNoFound./NumOpt;
mean_budget(5,:) = mean(samples(:,:,5),1);
var_budget(5,:) = var(samples(:,:,5),[],1);

%% PR Wilcoxon rank sum test
alpha = 0.05/(NumMethod-1);
PR_best_method = zeros(1,4);
PR_significant = zeros(NumMethod,4); % 1: better
PR_p = zeros(NumMethod,4);
for i = 1:4
    [~,PR_best_method(i)] = max(mean_budget(:,i));
    for j = 1:NumMethod
        [PR_p(j,i),PR_significant(j,i)] = ranksum(samples(:,i,PR_best_method(i)),samples(:,i,j),'alpha',alpha,'Tail','right');
    end
end
